
package com.cloud.common.client.spring;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;

import com.cloud.common.client.anno.EnableFeignClient;

public class EnableFeignImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
	@Override
	public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
		AnnotationAttributes annoAttrs = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableFeignClient.class.getName()));
        String[] basePackages = annoAttrs.getStringArray("value");
        //自定义的 包扫描器
        FeignClientClassPathBeanDefinitionScanner scanHandle = new FeignClientClassPathBeanDefinitionScanner(registry,false) ;
        //扫描指定路径下的接口
        scanHandle.doScan(basePackages);
	}
	
}
